<?php defined('IN_IA') or exit('Access Denied');?><?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/header', TEMPLATE_INCLUDEPATH)) : (include template('common/header', TEMPLATE_INCLUDEPATH));?>
<div class="main">
    <ul class="nav nav-tabs">
        <li <?php  if(($op=='display' || !$op)) { ?>class="active"<?php  } ?>><a href="<?php  echo $this->createWebUrl('Acmanage', array('op'=>'display'));?>">档期概况</a></li>
        <li <?php  if($op == 'list') { ?>class="active"<?php  } ?>><a href="<?php  echo $this->createWebUrl('Acmanage', array('op'=>'list'));?>">档期列表</a></li>
<li <?php  if((empty($id) && $op=='edit')) { ?>class="active"<?php  } ?>><a href="<?php  echo $this->createWebUrl('Acmanage', array('op'=>'edit'));?>">新增档期</a></li>

        <?php  if($just_do == 1) { ?>
        <li <?php  if((empty($id) && $op=='edit')) { ?>class="active"<?php  } ?>><a href="<?php  echo $this->createWebUrl('Acmanage', array('op'=>'edit'));?>">新增档期</a></li>
        <?php  if((!empty($id) && $op=='edit')) { ?>
		<li class="active"><a href="<?php  echo $this->createWebUrl('Acmanage', array('op'=>'edit', 'id'=>$id));?>">修改排期</a></li>
		<?php  } ?>
		<li  <?php  if(($op=='record')) { ?>class="active"<?php  } ?>><a href="<?php  echo $this->createWebUrl('Acmanage', array('op'=>'record'));?>">操作记录</a></li>
        <?php  } ?>
    </ul>
    
    <?php  if($op == 'edit') { ?>
    <div class="main">
		<form id="form" class="form-horizontal form" action="" method="post" enctype="multipart/form-data">
			<div class="panel panel-default">
				<div class="panel-heading">排期</div>
				<div class="panel-body">
				
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">日期</label>
						<div class="col-xs-12 col-sm-8">
							<?php  echo tpl_form_field_date('actime', date("Y-m-d",$actime))?>
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">标题</label>
						<div class="col-xs-12 col-sm-8">
							<input type="text" name="rows[title]" id="rows[title]" class="form-control" value="<?php  echo $list['title'];?>"/>
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">类型</label>
						<div class="col-xs-12 col-sm-8">
							 <select  class="form-control" name="rows[type]" id="fee-type">
							 	<option value=''>请选择</option>
								<?php  if(is_array($typearray)) { foreach($typearray as $k=>$v) { ?>
			                        <option value="<?php  echo $k;?>" <?php  if($row['type']== $k ) { ?>selected="selected"<?php  } ?>><?php  echo $v;?></option>
		                    	<?php  } } ?>
		                    </select>
						</div>
					</div>
					
					<div class="form-group ext-fee" style="display:none;">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">费用</label>
						<div class="col-xs-12 col-sm-8">
							<input type="text" name="rows[fee]" id="rows[fee]" class="form-control" value="<?php  echo $list['fee'];?>"/>
						</div>
					</div>
			
					<div class="form-group ext-fee" style="display:none;">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否开票</label>
						<div class="col-sm-9 col-xs-12">
							<label class="radio-inline"><input type="radio" name="rows[isbill]" value="1" <?php  if($list['isbill'] == 1) { ?>checked<?php  } ?>>是</label>
							<label class="radio-inline"><input type="radio" name="rows[isbill]" value="2" <?php  if($list['isbill'] == 2) { ?>checked<?php  } ?>>否</label>
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">位置</label>
						<div class="col-xs-12 col-sm-8">
							 <select  class="form-control" name="rows[rank]">
							 	<option value=''>请选择</option>
								<?php  if(is_array($rankarray)) { foreach($rankarray as $k=>$v) { ?>
			                        <option value="<?php  echo $k;?>" <?php  if($rank== $k ) { ?>selected="selected"<?php  } ?>><?php  echo $v;?></option>
			                    <?php  } } ?>
		                    </select>
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">内容对接</label>
						<div class="col-xs-12 col-sm-8">
							 <select  class="form-control" name="rows[content_people]">
							 	<option value=''>请选择</option>
								<?php  if(is_array($content_people_array)) { foreach($content_people_array as $k=>$v) { ?>
			                        <option value="<?php  echo $v;?>" <?php  if($list['content_people'] == $v ) { ?>selected="selected"<?php  } ?>><?php  echo $v;?></option>
			                    <?php  } } ?>
		                    </select>
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">商务对接</label>
						<div class="col-xs-12 col-sm-8">
							 <select  class="form-control" name="rows[business_people]">
							 	<option value=''>请选择</option>
								<?php  if(is_array($business_people_array)) { foreach($business_people_array as $k=>$v) { ?>
			                        <option value="<?php  echo $v;?>" <?php  if($list['business_people']== $v ) { ?>selected="selected"<?php  } ?>><?php  echo $v;?></option>
			                    <?php  } } ?>
		                    </select>
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">备注</label>
						<div class="col-xs-12 col-sm-8">
							<textarea name="rows[remark]" id="rows[remark]" class="form-control"><?php  echo $list['remark'];?></textarea>
						</div>
					</div>
					
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">状态</label>
						<div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
							<label class="radio-inline">
								<input type="radio" name="rows[status]" value="0" <?php  if($row['status'] == '0' || !$row['status']) { ?>checked<?php  } ?>> 已确定
							</label>
							<label class="radio-inline">
								<input type="radio" name="rows[status]" value="1" <?php  if($row['status'] == '1') { ?>checked<?php  } ?>> 预订位置
							</label>
						</div>
					</div>
	
					<div class="form-group">
						<div class="col-xs-12 col-sm-9 col-md-10 col-lg-10 col-sm-offset-3 col-md-offset-2 col-lg-offset-2">
							<input type="hidden" name="id" value="<?php  echo $list['id'];?>" />
							<input name="submit" type="submit" value="提交" class="btn btn-primary" />
							<input type="hidden" name="token" value="<?php  echo $_W['token'];?>" />
						</div>
					</div>
					
				</div>
			</div>
		</form>
	</div>

	<script>
	require(['jquery', 'util'], function($, util) {
		$(function() {
			$('#fee-type').on('change', function() {
				var type = $('#fee-type option:selected').val();
				if(type == 1 || type == 4) {
					$('.ext-fee').show();
				} else {
					$('.ext-fee').hide();
				}
			})
		
			$('#form').submit(function() {
				var type = $('#fee-type option:selected').val();
				
				if($('input[name="rows[title]"]').val() == ''){
					util.message('请填写标题');
					return false;
				}
				
				if($('select[name="rows[type]"] option:selected').val() == ''){
					util.message('请选择类型');
					return false;
				}
				
				if($('select[name="rows[rank]"] option:selected').val() == ''){
					util.message('请选择位置');
					return false;
				}
				
				if(type == 1 || type == 4) {
					if($('input[name="rows[fee]"]').val() == '' ){
						util.message('请填写费用');
						return false;
					}
					
					if($('input:radio[name="rows[isbill]"]:checked').val() == '' ){
						util.message('请选择是否开票');
						return false;
					}
				}
				
				return true;
			});
			
		});
	});
	</script>
	
	<?php  } else if($op == 'detail') { ?>
	
	<div class="form-horizontal form">
	<div class="panel panel-default">
		<div class="panel-heading">
			详情
		</div>
		<div class="panel-body">
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">日期</label>
				<div class="col-sm-10">
					<span class="help-block"><?php  echo date("Y-m-d",$row['actime'])?></span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">标题</label>
				<div class="col-sm-10">
					<span class="help-block"><?php  echo $row['title'];?></span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">类型</label>
				<div class="col-sm-10">
					<span class="help-block"><?php  echo $typearray[$row['type']];?></span>
				</div>
			</div>
			
			<?php  if(($row['type'] == '1' || $row['type'] == '4') && $row['fee'] != '') { ?>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">费用</label>
				<div class="col-sm-10">
					<span class="help-block"><?php  echo $row['fee'];?></span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否开票</label>
				<div class="col-sm-10">
					<span class="help-block">
					<?php  if($row['isbill'] == 1) { ?>
						是
					<?php  } else if($row['isbill'] == 2) { ?>
						否
					<?php  } else { ?>
						/
					<?php  } ?>
					</span>
				</div>
			</div>
			<?php  } ?>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">位置</label>
				<div class="col-sm-10">
					<span class="help-block"> <?php  echo $rankarray[$row['rank']];?></span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">内容对接</label>
				<div class="col-sm-10">
					<span class="help-block"><?php  if($row['content_people']) { ?><?php  echo $row['content_people'];?><?php  } else { ?>无<?php  } ?></span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">商务对接</label>
				<div class="col-sm-10">
					<span class="help-block"><?php  if($row['business_people']) { ?><?php  echo $row['business_people'];?><?php  } else { ?>无<?php  } ?></span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">备注</label>
				<div class="col-sm-10">
					<span class="help-block"><?php  if($row['remark']) { ?><?php  echo $row['remark'];?><?php  } else { ?>无<?php  } ?></span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">状态</label>
				<div class="col-sm-10">
					<span class="help-block"><?php  if($row['status']) { ?><span style="color:red;">预定占位</span><?php  } else { ?>正常<?php  } ?></span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">添加时间</label>
				<div class="col-sm-10">
					<span class="help-block"><?php  echo date("Y-m-d H:i:s",$row['addtime'])?></span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">添加人员</label>
				<div class="col-sm-10">
					<span class="help-block"><?php  echo $row['realname'];?></span>
				</div>
			</div>
			
			<?php  if($row['altertime']) { ?>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">最后修改时间</label>
				<div class="col-sm-10">
					<span class="help-block"><?php  echo date("Y-m-d H:i:s",$row['altertime'])?></span>
				</div>
			</div>
			<?php  } ?>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
				<div class="col-sm-10">
					<span class="help-block">
					<a href="javascript:history.go(-1);" class="btn btn-primary">返回</a>
                        <?php  if($just_do == 1) { ?>
					<a href="<?php  echo $this->createWebUrl('Acmanage', array('op'=>'edit','id'=>$row['id']));?>" class="btn btn-default" data-original-title="修改" title="">修改</a>
					<a href="<?php  echo $this->createWebUrl('Acmanage', array('op'=>'delete','id'=>$row['id']));?>" onclick="if(!confirm('删除后将不可恢复,确定删除吗?')) return false;" class="btn btn-default" data-original-title="查看图片" title="">删除</a>
					<?php  } ?>
					
					</span>
				</div>
			</div>
		</div>
	</div>
</div>

	<?php  } else if($op == 'record') { ?>
    <div class="panel panel-default">
        <div style="padding: 0 15px 0 15px;" style="position:relative">
            <table class="table table-hover" style="position: relative">
                <thead class="navbar-inner">
                    <tr>
                        <th width="100">序号</th>
                        <th width="200">账号</th>
						<th width="100">操作ID</th>
						<th width="200">操作时间</th>
						<th width="150">操作类型</th>
						<th>操作内容</th>
                    </tr>
                </thead>
                <tbody>
                    <?php  if(is_array($list)) { foreach($list as $row) { ?>
                    <tr>
                        <td><?php  echo $row['id'];?></td>
                        <td><?php  echo $row['username'];?></td>
						<td><?php  echo $row['uid'];?></td>
                        <td><?php  echo date("Y-m-d H:i:s",$row['addtime'])?></td>
                        <td><?php  echo $doarray[$row['type']];?></td>
                        <td><?php  echo $row['actitle'];?></td>
                    </tr>
                    <?php  } } ?>
                </tbody>
            </table>
        </div>
    </div>
    <?php  echo $pager;?>

    <?php  } else if($op == 'list') { ?>

    <div class="panel panel-info">
        <div class="panel-heading">筛选</div>
        <div class="panel-body">
            <form action="" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site">
                <input type="hidden" name="a" value="entry">
                <input type="hidden" name="m" value="knbsys_schedule">
                <input type="hidden" name="do" value="Acmanage">
                <input type="hidden" name="op" value="list">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">选择时间</label>
                    <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12"><?php  echo tpl_form_field_daterange('l_birth', $l_birth);?></div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">排期类型</label>
                    <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                        <select  class="form-control" name="l_type">
                            <option value=''>请选择</option>
                            <?php  if(is_array($typearray)) { foreach($typearray as $k=>$v) { ?>
                            <option value="<?php  echo $k;?>" <?php  if($l_type == $k ) { ?>selected="selected"<?php  } ?>><?php  echo $v;?></option>
                            <?php  } } ?>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">排期标题</label>
                    <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                        <input type="text" class="form-control" name="l_title" value="<?php  echo $l_title;?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">内容对接</label>
                    <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                        <input type="text" class="form-control" name="l_content_people" value="<?php  echo $l_content_people;?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">商务对接</label>
                    <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                        <input type="text" class="form-control" name="l_business_people" value="<?php  echo $l_business_people;?>">
                    </div>
                </div>
                <div class="form-group">
                    <div class="pull-right col-xs-12 col-sm-3 col-md-2 col-lg-2">
                        <button class="btn btn-default" data-original-title="" title=""><i class="fa fa-search"></i> 搜索</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <div class="panel panel-default">
        <div style="padding: 0 15px 0 15px;" style="position:relative">
            <table class="table table-hover" style="position: relative">
                <thead class="navbar-inner">
                <tr>
                    <th width="100">序号</th>
                    <th width="200">标题</th>
                    <th width="100">档期时间</th>
                    <th width="60">类型</th>
                    <th width="80">费用</th>
                    <th width="100">是否开票</th>
                    <th width="100">位置</th>
                    <th width="100">内容对接</th>
                    <th width="100">商务对接</th>
                    <th width="200">添加时间</th>
                </tr>
                </thead>
                <tbody>
                <?php  if(is_array($list)) { foreach($list as $row) { ?>
                <tr>
                    <td><?php  echo $row['id'];?></td>
                    <td><?php  echo $row['title'];?></td>
                    <td><?php  echo date("Y-m-d",$row['actime'])?></td>
                    <td><?php  echo $typearray[$row['type']];?></td>
                    <td><?php  if($row['fee']) { ?><?php  echo $row['fee'];?><?php  } else { ?>/<?php  } ?></td>
                    <td><?php  if($row['isbill'] == 1) { ?>是<?php  } else if($row['isbill'] == 2) { ?>否<?php  } else { ?>/<?php  } ?></td>
                    <td><?php  echo $rankarray[$row['rank']];?></td>
                    <td><?php  echo $row['content_people'];?></td>
                    <td><?php  echo $row['business_people'];?></td>
                    <td><?php  echo date("Y-m-d H:i:s",$row['addtime'])?></td>
                </tr>
                <?php  } } ?>
                </tbody>
            </table>
        </div>
    </div>
    <?php  echo $pager;?>

    <?php  } else { ?>
    <div class="panel panel-info">
		<div class="panel-heading">筛选</div>
		<div class="panel-body">
			<form action="" method="get" class="form-horizontal" role="form">
				<input type="hidden" name="c" value="site">
				<input type="hidden" name="a" value="entry">
				<input type="hidden" name="m" value="knbsys_schedule">
				<input type="hidden" name="do" value="Acmanage">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">选择时间</label>
					<div class="col-sm-9 col-md-8 col-lg-8 col-xs-12"><?php  echo tpl_form_field_daterange('birth', $birth);?></div>
				</div>
				<div class="form-group">
				<div class="pull-right col-xs-12 col-sm-3 col-md-2 col-lg-2">
					<button class="btn btn-default" data-original-title="" title=""><i class="fa fa-search"></i> 搜索</button>
				</div>
			</div>
			</form>
		</div>
	</div>
   <style>
	.tbd_show td{padding:0 !important;}
	.tbd_show ul{list-style-type: none;padding:0; width:100%;margin:0;}
	.tbd_show li{text-align:left;width:100%;height:40px;line-height:40px;border-bottom:1px solid #eee;}
	.tbd_show a{display:block;width:100%;height:100%}
	.tbd_show a:hover{background-color:#fff}
	.data-list th, .data-list li { text-align:center; }
    </style>
    <?php  for($n=0;$n<$pai;$n++){?>
    <div class="panel panel-default">
        <div style="padding: 0 15px 0 15px;" style="position:relative">
            <table class="table table-hover data-list" style="position: relative">
                <thead class="navbar-inner">
                    <tr>
                        <th width="50" style="text-align:center;">类别</th>
                        <?php  for($m=0;$m<7;$m++){?>
                        <?php  $nm = ($n*7)+$m?>
						<th style="text-align:center;">周<?php  echo $weekarray_show[$m];?>（<?php  echo $acday[$nm];?>）</th>
						<?php  }?>
                    </tr>
                </thead>
                <tbody class="tbd_show">
                    <tr>
                        <td width="9%">
                        	<ul>
                        		<li>头条</li>
                        		<li>次一</li>
                        		<li>次二</li>
                        		<li>次三</li>
                        		<li>次四</li>
                        	</ul>
                        </td>
                        
                        <?php  for($r=0;$r<7;$r++){?>
                        <?php  $nr = ($n*7)+$r?>
                        <td width="13%">
                        	<ul>
                        		<?php  for($s=1;$s<6;$s++){?>

                                    <?php  if($just_do == 1) { ?>
                                        <?php  if($acrows[$nr][$s]) { ?>
                                        <li><a <?php  if($red[$nr][$s]) { ?>style="color:red;"<?php  } ?> data-toggle="popover" rel="popover" data-content="标题：<?php  echo $acrows[$nr][$s];?><br />类型：<?php  echo $typearray[$actypes[$nr][$s]];?><br />商务对接：<?php  if($swdj[$nr][$s]) { ?><?php  echo $swdj[$nr][$s];?><?php  } else { ?>无<?php  } ?><br />内容对接：<?php  if($nrdj[$nr][$s]) { ?><?php  echo $nrdj[$nr][$s];?><?php  } else { ?>无<?php  } ?><br />" data-original-title="<?php  echo $acrows[$nr][$s];?>" href="<?php  echo $this->createWebUrl('Acmanage', array('op'=>'detail','actime'=>$actime[$nr],'rank'=>$s));?>"> [<?php  echo $typearray[$actypes[$nr][$s]];?>] <?php  echo $acrows[$nr][$s];?></a></li>
                                        <?php  } else { ?>
                                        <li><a href="<?php  echo $this->createWebUrl('Acmanage', array('op'=>'edit','actime'=>$actime[$nr],'rank'=>$s));?>"></a></li>
                                        <?php  } ?>
                                    <?php  } else { ?>
                                        <?php  if($acrows[$nr][$s]) { ?>
                                        <li><a <?php  if($red[$nr][$s]) { ?>style="color:red;"<?php  } ?> data-toggle="popover" rel="popover" data-content="标题：<?php  echo $acrows[$nr][$s];?><br />类型：<?php  echo $typearray[$actypes[$nr][$s]];?><br />商务对接：<?php  if($swdj[$nr][$s]) { ?><?php  echo $swdj[$nr][$s];?><?php  } else { ?>无<?php  } ?><br />内容对接：<?php  if($nrdj[$nr][$s]) { ?><?php  echo $nrdj[$nr][$s];?><?php  } else { ?>无<?php  } ?><br />" data-original-title="<?php  echo $acrows[$nr][$s];?>" href="<?php  echo $this->createWebUrl('Acmanage', array('op'=>'detail','actime'=>$actime[$nr],'rank'=>$s));?>"> [<?php  echo $typearray[$actypes[$nr][$s]];?>] <?php  echo $acrows[$nr][$s];?></a></li>
                                        <?php  } else { ?>
                                        <li><a href="#"></a></li>
                                        <?php  } ?>
                                    <?php  } ?>
                        		<?php  }?>
                        	</ul>
                        </td>
                        <?php  }?>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <?php  }?>
    <?php  } ?>

    <script>
        require(['bootstrap'], function(){

            $('[data-toggle="popover"]').popover({
                "html": true,
                "trigger": "hover"
            });
			
        });
    </script>
</div>
    <?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/footer', TEMPLATE_INCLUDEPATH)) : (include template('common/footer', TEMPLATE_INCLUDEPATH));?>
